#include <stdio.h>
#include <limits.h>

// "remove" is an API function of Linux
void arr_remove(int arr[], int pos, int arrsize) {
  for (int i = pos; i < arrsize - 1; i++) {
    arr[i] = arr[i + 1];
  }
}

int main() {
  int n;
  int arr[1024]={0};
  scanf("%d", &n);
  for(int i=0;i<n;i++){
    scanf("%d", &arr[i]);
    getchar();
  }

  int min_val = INT_MAX;
  int min_pos = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] < min_val) {
      min_val = arr[i];
      min_pos = i;
    }
  }

  // TODO: Refractor this code
  int pt = min_pos;
  int head = 1;
  while (n >= 2) {
    int curn = arr[pt];
    if (head == 0) {
      arr_remove(arr, pt, n);
      n--;
      pt--;
    }
    head = 0;
    
    pt += curn;
    pt = pt % n;
  }

  printf("%d", arr[0]);
}
